package o;

import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.extractor.Extractor;
import java.io.IOException;

public class afm implements Extractor {
    public static final adw ˏ = afk.ˎ;
    private ady ˊ;
    private boolean ˋ;
    private afq ॱ;

    public boolean ˎ(adv o_adv) throws IOException, InterruptedException {
        try {
            return ˏ(o_adv);
        } catch (ParserException e) {
            return false;
        }
    }

    public void ˏ(ady o_ady) {
        this.ˊ = o_ady;
    }

    public void ˊ(long j, long j2) {
        if (this.ॱ != null) {
            this.ॱ.ˏ(j, j2);
        }
    }

    public void ॱ() {
    }

    public int ˎ(adv o_adv, adz o_adz) throws IOException, InterruptedException {
        if (this.ॱ == null) {
            if (ˏ(o_adv)) {
                o_adv.ˏ();
            } else {
                throw new ParserException("Failed to determine bitstream type");
            }
        }
        if (!this.ˋ) {
            aef ˊ = this.ˊ.ˊ(0, 1);
            this.ˊ.ˊ();
            this.ॱ.ˋ(this.ˊ, ˊ);
            this.ˋ = true;
        }
        return this.ॱ.ˊ(o_adv, o_adz);
    }

    private boolean ˏ(adv o_adv) throws IOException, InterruptedException {
        afp o_afp = new afp();
        if (!o_afp.ˊ(o_adv, true) || (o_afp.ˊ & 2) != 2) {
            return false;
        }
        int min = Math.min(o_afp.ᐝ, 8);
        anc o_anc = new anc(min);
        o_adv.ˎ(o_anc.ˏ, 0, min);
        if (afj.ॱ(ˎ(o_anc))) {
            this.ॱ = new afj();
        } else if (aft.ॱ(ˎ(o_anc))) {
            this.ॱ = new aft();
        } else if (!afo.ˋ(ˎ(o_anc))) {
            return false;
        } else {
            this.ॱ = new afo();
        }
        return true;
    }

    private static anc ˎ(anc o_anc) {
        o_anc.ˋ(0);
        return o_anc;
    }
}
